const apiURL = 'http://47.94.23.135:8080';

const wxRequest = (params, url) => {
	wx.request({
		url,
		method: params.method || 'GET',
		data: params.data || {},
		header: {
			Accept: 'application/json',
			'Content-Type': 'application/json',
		},
		success(res) {
			if(params.success) {
				params.success(res);
			}
		},
		fail(res) {
			if(params.fail) {
				params.fail(res);
			}
		},
		complete(res) {
			if(params.complete) {
				params.complete(res);
			}
		},
	});
};


const sendSms = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/veriCode/sendSms');
};
const getCustomerInfo = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/customer/edit');
};
const loginByPhone = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/customer/loginByPhone');
};
const getCourseWXList = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/course/wxlist');
};
const getOrderList = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/order/list');
};
const orderWriteOff = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/order/orderWriteOff');
};
const customerQrCode = (params) => {
  wxRequest({ success: params.success ,data:params.data}, apiURL+'/sys/customerQrCode/getByCustomerId');
};

module.exports = {
  
  sendSms,
  getCustomerInfo,
  loginByPhone,
  getCourseWXList,
  getOrderList,
  orderWriteOff,
  customerQrCode
};